#include "c_list.h"
#include <stdio.h>
#include <iostream>

struct node_data{
    int _data;
};

int main()
{
    List* ls = ConstructList();

    for(int i=0;i<10;++i)
    {
        node_data* data = (node_data*)malloc(sizeof(node_data));
        data->_data = i; 
        PushBack(ls,(void*)data);       
    }

    for(ListNode* cur=Begin(ls);cur != End(ls);cur = cur->next)
    {
        struct node_data* pData = (struct node_data*)cur->data;
        printf("%d\n",pData->_data);
    }

    printf("\n");

    for(ListNode* cur=RBegin(ls);cur != REnd(ls);cur = cur->prev)
    {
        struct node_data* pData = (struct node_data*)cur->data;
        printf("%d\n",pData->_data);
    }

    if(ExistNode(ls,Begin(ls)))
    {
        printf("node exist,%d\n",((struct node_data*)Begin(ls)->data)->_data);
    }

    for(ListNode* cur=Begin(ls);cur != End(ls);)
    {
        struct node_data* pData = (struct node_data*)cur->data; 
        free((void*)pData);
        pData = NULL;
        ListNode* tmp = cur->next;
        DestructListNode(cur);
        cur = tmp;
    }

    Clear(ls);

    for(ListNode* cur=RBegin(ls);cur != REnd(ls);cur = cur->prev)
    {
        struct node_data* pData = (struct node_data*)cur->data;
        printf("%d\n",pData->_data);
    }

    DestructList(ls);
    return 0;
}